<template>
	<Layout class="p-5 bg-white">
		<Form :label-width="80">
			
			<FormItem class="w-50" label="门禁型号">
				<Input v-model="access.modelNumber" placeholder="请输入门禁型号"></Input>
			</FormItem>
			<FormItem class="w-50" label="设备ID">
				<Input v-model="access.uId" placeholder="请输入设备ID"></Input>
			</FormItem>
			<FormItem class="w-50" label="授权Key">
				<Input v-model="access.uKey" placeholder="请输入授权Key"></Input>
			</FormItem>
			<FormItem class="w-50" label="序列号">
				<Input v-model="access.sn" placeholder="请输入序列号"></Input>
			</FormItem>
			<FormItem class="" label="进/出门">
				<RadioGroup v-model="ioFlg">
				        <Radio label= true>
				            <span>进门</span>
				        </Radio>
				        <Radio label= false>
				            <span>出门</span>
				        </Radio>
				    </RadioGroup>
			</FormItem>
			</FormItem>
			<FormItem class="text-right"> 
				<Button @click="submit" type="primary">提交</Button>
				<Button @click="cancel" class="ml-2">取消</Button>
			</FormItem>
		</Form>
	</Layout>
</template>

<script>
	export default {
		data() {
			return {
				access: {
					modelNumber: "",
					uId: "",
					uKey: "",
					sn: ""
				},
				ioFlg:"",
				storeId:""
			}
		},
		methods: {
			cancel: function() {
				this.$tabs.close();
			},
			submit: function() {
				if (this.$data.access.modelNumber.length === 0) {
					this.message.error("门禁型号必须输入");
					return;
				}
				
				if (this.$data.access.uId.length === 0) {
					this.message.error("设备ID必须输入");
					return;
				}
				
				if (this.$data.access.uKey.length === 0) {
					this.message.error("授权Key必须输入");
					return;
				}
				
				if (this.$data.access.sn.length === 0) {
					this.message.error("序列号必须输入");
					return;
				}
				
				if (this.$data.ioFlg.length === 0 ){
					this.message.error("进出门必须选择");
					return;
				}
				let self = this;
				this.$data.access
				this.http.post({
					
					url: "/store/access/info",
					param: {
						access:this.$data.access,
						storeId:this.$data.storeId,
						ioFlg:this.$data.ioFlg
						
					}
				}).then(data => {
					self.message.info("新增成功");
					this.$tabs.close();
				});
				
			}
		},
		
		created: function () {
			this.$data.storeId = this.$route.params.storeId;
		}
	}
</script>

<style>
</style>
